<?php
/**
 * SocialEngine
 *
 * @category   Application_Core
 * @package    Core
 * @copyright  Copyright 2006-2010 Webligo Developments
 * @license    http://www.socialengine.net/license/
 * @author     Jung
 */

/**
 * @category   Application_Core
 * @package    Core
 * @copyright  Copyright 2006-2010 Webligo Developments
 * @license    http://www.socialengine.net/license/
 */
class Core_Form_Admin_Widget_Logo extends Core_Form_Admin_Widget_Standard {
	public function init() {
		parent::init ();
		
		// Set form attributes
		$this->setTitle ( 'Site Logo' )->setDescription ( 'Shows your site-wide main logo or title.  IIImages are uploaded via the File Media Manager.' );
		
		// Get available files
		$logoOptions = array ('' => 'Text-only (No logo)' );
		$imageExtensions = array ('gif', 'jpg', 'jpeg', 'png' );
		
		$it = new DirectoryIterator ( APPLICATION_PATH . '/public/admin/' );
		foreach ( $it as $file ) {
			if ($file->isDot () || ! $file->isFile ())
				continue;
			$basename = basename ( $file->getFilename () );
			if (! ($pos = strrpos ( $basename, '.' )))
				continue;
			$ext = strtolower ( ltrim ( substr ( $basename, $pos ), '.' ) );
			if (! in_array ( $ext, $imageExtensions ))
				continue;
			$logoOptions ['public/admin/' . $basename] = $basename;
		}
		
		$this->addElement ( 'Select', 'logo', array ('label' => 'Site Logo', 'multiOptions' => $logoOptions ) );
	}
}